﻿using System;
using System.Text;

namespace dotHTML.HTML {
    /// <summary>
    /// Represents the title of a table.
    /// </summary>
    [Serializable]
    public class Caption : Element {

        /// <summary>
        /// Defines the alignment of a table.
        /// </summary>
        public enum AlignmentChoices {
            /// <summary>
            /// The item is aligned at the bottom of the table.
            /// </summary>
            Bottom,
            /// <summary>
            /// The item is aligned at the left of the table.
            /// </summary>
            Left,
            /// <summary>
            /// The item is aligned at the right of the table.
            /// </summary>
            Right,
            /// <summary>
            /// The item is aligned at the top of the table.
            /// </summary>
            Top
        }

        private AlignmentChoices? _align;

        /// <summary>
        /// Determines where the caption is aligned with respect to the table.
        /// </summary>
        [Obsolete("Deprecated in HTML4 - use CSS instead.")]
        public AlignmentChoices? Align {
            get { return _align; }
            set { _align = value; }
        }

        /// <summary>
        /// Gets a formatted string of all local attributes of this element
        /// (not including the base attributes).
        /// </summary>
        /// <param name="sb">The StringBuilder to write this element's
        /// attribute data to.</param>
        protected override void WriteLocalAttributes(StringBuilder sb) {
            AttributeWriter.Write(sb, _align, "align", true);
        }
    }
}
